import { useFocusEffect } from '@react-navigation/native';
import { useCallback } from 'react';

function useHideTabBar(navigation) {
  useFocusEffect(
    useCallback(() => {
      const parentNavigator = navigation.getParent();
      if (parentNavigator) {
        parentNavigator.setOptions({ tabBarStyle: { display: 'none' } });
      }

      return () => {
        if (parentNavigator) {
          parentNavigator.setOptions({ tabBarStyle: { display: '' } }); // Reset to default
        }
      };
    }, [navigation])
  );
}

export default useHideTabBar;
